Skip to content

Conversation

@asmertpc-cloud
Copy link

fix for windows

fix for windows
@matthewdouglas
Copy link
Member

Hi,

Can you please clarify what it is that is being fixed for Windows? What parts of unistd.h are actually needed? I assume this is for AMD GPUs on Windows, is that right? Preferably dependencies like #1834 and #1835 would be included in the same PR; but ideally I would not want to add any more code than necessary.

@asmertpc-cloud
Copy link
Author

asmertpc-cloud commented Jan 11, 2026

Hi
Sorry, I'm not quite comfortable with Git yet.
You're right, it's for AMD GPUs running Windows.
I closed #1834 and #1835, but calling unistd.h needs to be done like this.

#ifndef _UNISTD_H
#define _UNISTD_H`

/* Checking that we're on Windows */
#if defined(_WIN32) || defined(_WIN64)

#include <io.h>
#include <process.h>
#include <direct.h>
#include <stdlib.h>

/* Access Constants (POSIX -> Windows) /
#define F_OK 0
#define X_OK 1 /
В Windows реально нет проверки на исполнение через access */
#define W_OK 2
#define R_OK 4

/* Standard Descriptors */
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2

/*
Macros for functions.
We use host for HIP compatibility,
so the compiler knows where these functions are available.
*/
#ifdef __cplusplus
extern "C" {
#endif

#define access _access
#define chdir _chdir
#define close _close
#define dup _dup
#define dup2 _dup2
#define getpid _getpid
#define isatty _isatty
#define lseek _lseek
#define read _read
#define rmdir _rmdir
#define unlink _unlink
#define write _write

#ifdef _MSC_VER
/* MSVC doesn't have a sleep function; we use the Windows API. */
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#define sleep(x) Sleep((x) * 1000)
#define usleep(x) Sleep((x) / 1000)
#endif

#ifdef __cplusplus
}
#endif

#else
/* If we're not on Windows, we just pass in the real unistd.h. */
#include <unistd.h>
#endif

#endif /* _UNISTD_H */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants